
using System;
using AtDevice;

namespace GtkControls
{
    
    [System.ComponentModel.Category("GtkControls")]
    [System.ComponentModel.ToolboxItem(true)]
    public partial class StatusbarWidget : Gtk.Bin
    {
        
        public StatusbarWidget()
        {
            this.Build();
            DeviceHandler.DeviceOpened += delegate(AtDevice.AtDevice dev) {
                dev.GetInterface<IHuaweiInterface>().FlowUpdated += FlowUpdated;
            };
        }
        
        void FlowUpdated(int uptime, int dlSpeed, int ulSpeed, long dlBytes, long ulBytes)
        {
            Gtk.Application.Invoke(delegate
            {
                speedLabel.Text = String.Format("D: {0}/s U: {1}/s", StringUtils.FormatBytes(dlSpeed), StringUtils.FormatBytes(ulSpeed));
                transferredLabel.Text = String.Format("D/U: {0}/{1}", StringUtils.FormatBytes(dlBytes), StringUtils.FormatBytes(ulBytes));
            });
        }
    }
}
